package newapproach.parser;

import java.io.File;
import java.util.Iterator;

import newapproach.elements.YTable;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

public class YParser {

	public static void main(String[] args){
		try {
			Document document = parse("C:\\Users\\Nissim\\s3\\workspace\\springapp\\src\\t.xml");
			for(Iterator<Element> it =document.getRootElement().elementIterator(); it.hasNext();){
				Element element = it.next();
//				System.out.println(element.getQualifiedName());
//				System.out.println(element.elements().size());
//				System.out.println("+"+element.getText());
//				System.out.println("-"+element.attributeValue("name"));
				if(element.getQualifiedName().equals("y_table")){
					YTable t = new YTable(element);
					System.out.println(t.toJsp());
				}
			}
//			System.out.println("YYY");
		} catch (DocumentException e) {
			e.printStackTrace();
		}
	}

	public static Document parse(String path) throws DocumentException {
		File f = new File(path);
		SAXReader reader = new SAXReader();
		Document document = reader.read(f);
		return document;
	}
	
	
}
